<div id="actionbar">
    {if $status == 4}
    <div class="fn-left">
        <a href="javascript:;" class="button button-blue bar" url="{:url("popupshop/order/alldelete")}" msg="【彻底删除】选择商品" issale="0">清空回收站</a>
    </div>
    {/if}  
    {if $status != 4}
    <div class="fn-left">
        <a href="{:url('popupshop/order/excel',['status' => $status,'starttime' => date('Y-m-d',$starttime),'endtime' => date('Y-m-d',$endtime)])}" class="button button-green">导出表格</a>
    </div>
    {/if}
    <div class="fn-right pl5">
        <form id="form" action="{:url('popupshop/order/index')}" method="get">
            <input type="hidden" name="status" value="{$status}" />
            <input readonly placeholder="开始时间" class="input ui-date w100" type="text" name="starttime" value="{if $starttime}{$starttime|date="Y-m-d"}{/if}" /> 至 
            <input readonly placeholder="结束时间" class="input ui-date w100" type="text" name="endtime" value="{if $endtime}{$endtime|date="Y-m-d"}{/if}" />
            <input placeholder="订单编号" class="input w150" type="text" name="keyword" value="{$keyword}" />
            <input type="submit" value="搜索" class="button button-blue" />
        </form>
    </div>
    <div class="fn-right button-group">
        <a href="{:url('popupshop/order/index')}" class="button {if !$status} button-green{/if}">全部商品</a>
        <a href="{:url('popupshop/order/index',['status'=>1])}" class="button {if $status ==1} button-green{/if}">未付款</a>
        <a href="{:url('popupshop/order/index',['status'=>2])}" class="button {if $status ==2} button-green{/if}">已付款</a>
        <a href="{:url('popupshop/order/index',['status'=>3])}" class="button {if $status ==3} button-green{/if}">已发货</a>
        <a href="{:url('popupshop/order/index',['status'=>5])}" class="button {if $status ==5} button-green{/if}">已结单</a>
        <a href="{:url('popupshop/order/index',['status'=>4])}" class="button {if $status ==4} button-green{/if}">回收站</a>
    </div>
</div>
<div class="cards">
    <div class="card green">
        <div class="fn-left"><i class="iconfont icon-my_icon"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$count}</div><div class="text">总数量</div></div>
    </div>
    <div class="card yellow">
        <div class="fn-left"><i class="iconfont icon-renminbi1688"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$no_payment|money}</div><div class="text">未付款金额</div></div>
    </div>
    <div class="card yellow">
        <div class="fn-left"><i class="iconfont icon-renminbi1688"></i></div>
        <div class="fn-right fn-tar"><div class="num">{$payment|money}</div><div class="text">已付款金额</div></div>
    </div>
</div>
<table class="pure-table">
    <thead>
        <tr>
            <th>订单详情</th>
            <th class="w100 fn-tac">订单金额</th>
            <th class="w100 fn-tac">交易状态</th>
        </tr>
    </thead>
    {foreach $order as $order_no => $rs}
    <tbody>
        <tr class="pure-table-title">
            <td colspan="5" class="fn">
            <div class="fn-left">
                {$rs.order_starttime}</span>&nbsp;&nbsp;订单号: <a href="javascript:openwin('{:url('popupshop/order/view',['order_no' => $rs.order_no])}')">{$rs.order_no}</a>
            </div>
            <div class="fn-right button-group">
                {if $rs.status}
                    <a href="javascript:;" class="button button-mini button-disabled">结束订单</a>
                {else}
                    {if $rs.paid_at}
                    {if $rs.express_status == 0}
                        <a  href="javascript:;" url="{:url('popupshop/order/sendgoods',['order_no' =>$rs.order_no])}" class="win button button-red button-mini">订单发货</a>
                    {else}
                        <a href="javascript:;" class="button button-mini button-green bar" url="{:url('popupshop/order/completion',['order_no'=>$rs.order_no,'status' => $status])}" msg="您确定要改为已签收">确认签收</a>
                    {/if}
                    {else}
                        <a href="javascript:;" class="button button-mini button-green bar" url="{:url('popupshop/order/force_completion',['order_no'=>$rs.order_no,'status' => $status])}" msg="您确定要结束当前订单">结束订单</a>
                    {/if}
                {/if}
                {if $rs.is_del == 0 && $rs.paid_at == 0}
                <a href="javascript:;" class="button button-mini button-violet bar" url="{:url('popupshop/order/delete',['order_no'=>$rs.order_no,'status' => $status])}" msg="确认要删除当前订单">删除订单</a>
                {else}
                    <a href="javascript:;" class="button button-mini button-disabled">删除订单</a>
                {/if}
            </div>
            </td>
        </tr>
        <tr>
            <td>
                {foreach $rs.item as $vo}
                <div class="fn-clear order">
                    <div class="img fn-left"><img src="{$vo.img}?x-oss-process=style/80" /></div>
                    <div class="info">{$vo.name}<br ><span class="gray">{$vo.note}</span></div>
                    <div class="number fn-right">￥{$vo.buy_price} x {$vo.buy_nums}</div>
                </div>
                {/foreach}
            </td>
            <td class="fn-tac">￥{$rs.order_amount}</td>
            <td class="fn-tac">
                {if $rs.is_del ==1}
                    <span class="badge">已删除</span>
                {else}
                    {if $rs.status == 1}
                        <span class="badge">已完成</span>
                    {else}
                        {if $rs.paid_at}
                            {if $rs.express_status}
                                <span class="badge bg-green">已发货</span>
                            {else}
                                <span class="badge bg-blue">待发货</span>    
                            {/if}
                        {else}
                            <span class="badge bg-red">待付款</span>
                        {/if}
                    {/if}
                {/if}
            </td>
        </tr>
    </tbody>
    {/foreach}
</table>
{$lists|raw}
<style type="text/css">
    .order {border-bottom: 1px #e9ecf3 solid;display: flex;}
    .order:last-child{border-bottom:none}
    .order div {margin: 5px;}
    .order .img {width: 80px;height: 80px;overflow: hidden;border: 1px dotted #e9ecf3;padding: 2px;}
    .order .img img {width: 78px;}
    .order .info {line-height: 25px;margin-top: 10px;display: block;flex: 1px;}
    .order .info .gray {color: #9e9e9e;font-size: 12px;}
    .order .number {line-height: 50px;margin: 10px 20px;}
</style>
<script type="text/javascript">
    Do('base', 'layer','form','date', function () {
        $('#form').isForm({types:1});
        $('.win').win({'reload':1});
        $(".bar").click(function() {
            var url = $(this).attr('url');
            var msg = $(this).attr('msg');
            tools_submit({action:url,msg:msg})
        })
    })
</script>